package br.ita.escolaita.model.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

@Entity
@Table(name="FREQUENCIA")
public class Frequencia implements Serializable{

    @Transient
    private static final long serialVersionUID = 2367665649210558607L;

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    @Column
    private Integer id;

    @Column
    @Temporal(TemporalType.DATE)
    private Date dataFrequencia;

    @Column
    private boolean presente;

    @ManyToOne
    private Aluno aluno;

    // Construtor Default
    public Frequencia() {}

    /**
     * @return the id
     */
    public Integer getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(Integer id) {
        this.id = id;
    }

    /**
     * @return the dataFrequencia
     */
    public Date getDataFrequencia() {
        return dataFrequencia;
    }

    /**
     * @param dataFrequencia the dataFrequencia to set
     */
    public void setDataFrequencia(Date dataFrequencia) {
        this.dataFrequencia = dataFrequencia;
    }

    public Aluno getAluno() {
        return aluno;
    }

    public void setAluno(Aluno aluno) {
        this.aluno = aluno;
    }

    public boolean isPresente() {
        return presente;
    }

    public void setPresente(boolean presente) {
        this.presente = presente;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Frequencia other = (Frequencia) obj;
        if (this.dataFrequencia != other.dataFrequencia && (this.dataFrequencia == null || !this.dataFrequencia.equals(other.dataFrequencia))) {
            return false;
        }
        if (this.aluno != other.aluno && (this.aluno == null || !this.aluno.equals(other.aluno))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 97 * hash + (this.dataFrequencia != null ? this.dataFrequencia.hashCode() : 0);
        hash = 97 * hash + (this.aluno != null ? this.aluno.hashCode() : 0);
        return hash;
    }


}